package com.easyedu.core.dao;

import com.easyedu.core.entity.po.BuildingAddress;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author lmr
 **/
@Mapper
public interface BuildingAddressDao {

     /**
      * 功能描述:获取建筑信息
      *
      * @param belongBuild 1 建筑名
      * @return : com.easyedu.api.entity.DO.BuildingAddress
      **/
     @Select("select * from building_address where build_name = #{belongBuild}")
     BuildingAddress getByName(String belongBuild);

     /**
      * 功能描述:获取所有教室信息
      *
      * @return : java.util.List<com.easyedu.api.entity.DO.BuildingAddress>
      **/
     @Select("select * from building_address")
     List<BuildingAddress> getBuild();

     /**
      * 获取最大教室的层数
      *
      * @param buildName 教学楼名
      * @return 最大层数
      */
     @Select("select max(floor) from classroom where belong_build = #{buildName}")
     int getBuildingMaxFloor(String buildName);

     /**
      * 插入一个教学楼
      *
      * @param buildName 教学楼名
      * @param x         经度
      * @param y         纬度
      * @return 插入成功条数
      */
     @Insert("insert into building_address set build_name = #{buildName}, X = #{x} ,Y = #{y}")
     Integer add(String buildName, double x, double y);

     /**
      * 通过id查询教学楼
      *
      * @param buildingId 教学楼id
      * @return 教学楼信息
      */
     @Select("select * from building_address where building_id = #{buildingId}")
     BuildingAddress getById(int buildingId);

     @Update("update building_address set build_name = #{buildName},X = #{x},Y = #{y} where building_id = "
             + "#{buildingId}")
     Integer updateById(int buildingId, String buildName, double x, double y);

     @Delete("delete from building_address where building_id = #{buildingId}")
     Integer deleteById(int buildingId);
}
